package com.itheima.mapper;

import com.itheima.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Encounter
 * @date 2024/10/15 16:52<br/>
 */
@Mapper
public interface UserMapper
    {
        
        /**
         * 按用户名加载用户
         *
         * @param username 用户名
         * @return {@link User }
         */
        @Select("select * from t_user where username = #{username}")
        User loadUserByUsername(String username);
        
        /**
         * 获取身份验证列表
         *
         * @param username 用户名
         * @return {@link List }<{@link String }>
         */
        @Select("select p.keyword from t_user u " +
                "left join t_user_role ur on u.id = ur.user_id " +
                "left join t_role_permission rp on rp.role_id = ur.role_id " +
                "left join t_permission p on rp.permission_id = p.id " +
                "where username = #{username} ")
        List<String> getAuthList(String username);
    }
